Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

records: Add examples about library and application use #764

Merged
merged 2 commits into from
Dec 7, 2024
Merged

Conversation

amotl
Copy link
Member

@amotl amotl commented Dec 7, 2024

About

Add a few examples that use the Records library and program together with CrateDB.

Records is a very simple, but powerful, library for making raw SQL queries to most relational databases.

-- https://pypi.org/project/records/

Synopsis

pip install --upgrade records sqlalchemy-cratedb

CLI

records "SELECT * FROM sys.summits WHERE region ILIKE :region" region="ortler%"

Library

from pprint import pprint
import records

# Define database connection URL, suitable for CrateDB on localhost.
# For CrateDB Cloud, use `crate://<username>:<password>@<host>`.
db = records.Database("crate://")

# Invoke query.
rows = db.query("SELECT * FROM sys.summits ORDER BY height DESC LIMIT 3")
data = rows.all()
pprint(data)

References

/cc @karynzv, @simonprickett, @surister, @hammerhead, @hlcianfagna, @wierdvanderhaar, @zolbatar

@amotl amotl force-pushed the python-records branch 3 times, most recently from 9dcc72c to de29225 Compare December 7, 2024 08:45
@amotl amotl marked this pull request as ready for review December 7, 2024 09:46
@amotl amotl merged commit 4efcd1c into main Dec 7, 2024
4 checks passed
@amotl amotl deleted the python-records branch December 7, 2024 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant